package file

import (
	"data-center/pkg/queue"
	"go.mongodb.org/mongo-driver/mongo"
	"gorm.io/gorm"
	"net/http"

	"github.com/gin-gonic/gin"
)

// Handler 任务处理器
type Handler struct {
	// 注入服务依赖
	db       *gorm.DB
	mongo    *mongo.Collection
	producer queue.Producer
}

// NewHandler 创建任务处理器
func NewHandler(db *gorm.DB, mongoClient *mongo.Collection, producer queue.Producer) *Handler {
	return &Handler{
		db:       db,
		mongo:    mongoClient,
		producer: producer,
	}
}

// RegisterRoutes 注册路由
func (h *Handler) RegisterRoutes(r *gin.RouterGroup) {
	files := r.Group("/files")
	{
		files.POST("/", h.Upload)
		files.GET("/:id", h.Get)
	}
}

// Upload 上传文件
func (h *Handler) Upload(c *gin.Context) {
	c.JSON(http.StatusOK, gin.H{"message": "File uploaded"})
}

// Get 获取文件详情
func (h *Handler) Get(c *gin.Context) {
	id := c.Param("id")
	c.JSON(http.StatusOK, gin.H{"id": id, "message": "File details"})
}
